﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media.Animation;
using GurLoader;
using GurLoader.View;
using NUnit.Framework;

namespace GurLoaderWPF.Test.View
{
    [TestFixture]
    public class TaskCommandDescriptionConverterTests
    {

        [Test]
        public void CreateInstanceTest()
        {
            var conv = new TaskCommandDescriptionConverter();

            Assert.IsNotNull(conv);
        }

        [Test]
        public void ConvertTest()
        {
            var conv = new TaskCommandDescriptionConverter();
            Assert.IsNotNull(conv);

            List<string> resultStrings = new List<string>();
            foreach (var cmd in Enum.GetValues(typeof (Command)).Cast<Command>())
            {
                string result = conv.Convert(cmd, typeof (String), null, CultureInfo.InvariantCulture) as string;
                if (result == null)
                    Assert.Fail("Could not convert command.");

                if (resultStrings.Contains(result))
                    Assert.Fail("Duplicate description found. Each description should be unique.");

                resultStrings.Add(result);
            }
            
        }

        [Test]
        public void ConvertNonCommandObjectTest()
        {
            var conv = new TaskCommandDescriptionConverter();
            Assert.IsNotNull(conv);

            string result = conv.Convert(25, typeof (String), null, CultureInfo.InvariantCulture) as string;

            if ( result == null )
                Assert.Fail("Could not convert unknown object type.");

        }

        [Test]
        public void ConvertNullTest()
        {
            var conv = new TaskCommandDescriptionConverter();
            Assert.IsNotNull(conv);

            string result = conv.Convert(null, typeof(String), null, CultureInfo.InvariantCulture) as string;

            if (result == null)
                Assert.Fail("Could not convert null object.");
        }

        [Test]
        [ExpectedException(typeof(NotImplementedException))]
        public void ConvertBackTest()
        {
            var conv = new TaskCommandDescriptionConverter();
            Assert.IsNotNull(conv);

            conv.ConvertBack(new object(), typeof (String), null, CultureInfo.CurrentCulture);

            Assert.Fail("Execption not thrown.");
        }
    }
}
